Non-quick instruction accelerator including instruction identifier and data set storage and method of implementing same

ABSTRACT

An instruction accelerator which includes a processor and an associative memory. The processor is coupled to receive a stream of instructions and a corresponding stream of instruction identifier values. The instructions include at least one non-quick instruction which has a first associated data set which must be accessed prior to executing the non-quick instruction. A memory, which is coupled to the processor, stores one or more instruction identifier values and one or more associated data sets. The memory receives the stream of instruction identifier values. When a current instruction identifier value in the stream of instruction identifier values matches an instruction identifier value stored in the memory, an associated data set is accessed from the memory. More specifically, if the first instruction identifier value and the first data set are stored in the memory, and the current instruction identifier value is equal to the first instruction identifier value, then the first data set is read out of the memory. Execution of the non-quick instruction is accelerated because the first data set is readily accessible within the memory. If the first data set is not stored in the memory, the associative memory and the processor control the initial retrieval of the first data set.

RELATED APPLICATIONS

This application claims the benefit of U.S. Provisional Application Ser. No. 60/010,527, filed Jan. 24, 1996, entitled "Methods and Apparatuses for Implementing the JAVA Virtual Machine" (JAVA is a trademark of Sun Microsystems, Inc.) and naming Marc Tremblay, James Michael O'Connor, Robert Garner, and William N. Joy as inventors, and is a continuation-in-part application of U.S. application Ser. No. 08/646,442, now abandoned, filed May 7, 1996, entitled "Apparatus and Method for Enhancing the Operational Speed of the JAVA Virtual Machine", and naming Marc Tremblay and James Michael O'Connor as inventors that also claimed the benefit of U.S. Provisional Application Ser. No. 60/010,527, filed Jan. 24, 1996, entitled "Methods and Apparatuses for Implementing the JAVA Virtual Machine" and naming Marc Tremblay, James Michael O'Connor, Robert Garner, and William N. Joy as inventors.

REFERENCE TO SECTION I

A portion of the disclosure of this patent document including Section I, The JAVA Virtual Machine Specification and Section A thereto, contains material which is subject to copyright protection. The copyright owner has no objection to the facsimile reproduction by anyone of the patent document or the patent disclosure, as it appears in the U.S. Patent and Trademark Office patent files or records, but otherwise reserves all copyright rights whatsoever.

BACKGROUND OF THE INVENTION

1. Field of the Invention

The present invention relates generally to computer systems, and in particular, to the accelerated execution of instructions in a computer system.

2. Discussion of Related Art

Many individuals and organizations in the computer and communications industries tout the Internet as the fastest growing market on the planet. In the 1990s, the number of users of the Internet appears to be growing exponentially with no end in sight. In June of 1995, an estimated 6,642,000 hosts were connected to the Internet; this represented an increase from an estimated 4,852,000 hosts in January, 1995. The number of hosts appears to be growing at around 75% per year. Among the hosts, there were approximately 120,000 networks and over 27,000 web servers. The number of web servers appears to be approximately doubling every 53 days.

In July 1995, with over 1,000,000 active Internet users, over 12,505 usenet news groups, and over 10,000,000 usenet readers, the Internet appears to be destined to explode into a very large market for a wide variety of information and multimedia services.

In addition, to the public carrier network or Internet, many corporations and other businesses are shifting their internal information systems onto an intranet as a way of more effectively sharing information within a corporate or private network. The basic infrastructure for an intranet is an internal network connecting servers and desktops, which may or may not be connected to the Internet through a firewall. These intranets provide services to desktops via standard open network protocols which are well established in the industry. Intranets provide many benefits to the enterprises which employ them, such as simplified internal information management and improved internal communication using the browser paradigm.

Integrating Internet technologies with a company's enterprise infrastructure and legacy systems also leverages existing technology investment for the party employing an intranet. As discussed above, intranets and the Internet are closely related, with intranets being used for internal and secure communications within the business and the Internet being used for external transactions between the business and the outside world. For the purposes of this document, the term "networks" includes both the Internet and intranets. However, the distinction between the Internet and an intranet should be born in mind where applicable.

In 1990, programmers at Sun Microsystems wrote a universal programming language. This language was eventually named the JAVA programming language. JAVA and JAVA-based trademarks are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. The JAVA programming language resulted from programming efforts which initially were intended to be coded in the C++ programming language; therefore, the JAVA programming language has many commonalities with the C++ programming language. However, the JAVA programming language is a simple, object-oriented, distributed, interpreted yet high performance, robust yet safe, secure, dynamic, architecture neutral, portable, and multi-threaded language.

The JAVA programming language has emerged as the programming language of choice for the Internet as many large hardware and software companies have licensed it from Sun Microsystems. The JAVA programming language and environment is designed to solve a number of problems in modern programming practice. The JAVA programming language omits many rarely used, poorly understood, and confusing features of the C++ programming language. These omitted features primarily consist of operator overloading, multiple inheritance, and extensive automatic coercions. The JAVA programming language includes automatic garbage collection that simplifies the task of programming because it is no longer necessary to allocated and free memory as in the C programming language. The JAVA programming language restricts the use of pointers as defined in the C programming language, and instead has true arrays in which array bounds are explicitly checked, thereby eliminating vulnerability to many viruses and nasty bugs. The JAVA programming language includes objective-C interfaces and specific exception handlers.

The JAVA programming language has an extensive library of routines for coping easily with TCP/IP protocol (Transmission Control Protocol based on Internet protocol), HTTP (Hypertext Transfer Protocol) and FTP (File Transfer Protocol). The JAVA programming language is intended to be used in networked/distributed environments. The JAVA programming language enabled the construction of virus-free, tamper-free systems. The authentication techniques are based on public-key encryption.

Many computer systems, including those implementing the JAVA virtual machine specification, implement instructions which require that additional data be located and retrieved prior to executing the instruction. Within the JAVA virtual machine specification, the location and retrieval of such data is referred to as resolving a constant pool entry. Instructions which require that data be located and retrieved prior to execution are hereinafter generally referred to as non-quick instructions. Locating and retrieving the data required to execute a non-quick instruction can take hundreds of cycles. It would therefore be desirable to have a method and apparatus for accelerating the execution of non-quick instructions.

A conventional method for accelerating the execution of a non-quick instruction involves the steps of (1) retrieving the original instruction code from a discrete location in program memory, (2) locating and retrieving the data required to execute the non-quick instruction, (3) modifying the original instruction code to include the retrieved data and then (4) overwriting the original instruction code at the discrete location in the program memory with the modified instruction code. The modified instruction code is subsequently executed in place of the original instruction code. This is commonly referred to as self-modifying code. One disadvantage with self-modifying code is that once the original instruction code has been modified, the original instruction code is no longer available. The unavailability of the original instruction code can hamper subsequent program debugging. Another disadvantage is that the discrete location in the memory may not have sufficient capacity to store the modified instruction code (which includes the retrieved data). In certain prior art applications, the original instruction code is stored in a read only memory (ROM). In such applications, it is not possible to overwrite the original instruction code with a modified instruction code.

It would therefore be desirable to have an instruction accelerator which accelerates the execution of non-quick instructions in a manner which overcomes the above-described shortcomings of the prior art.

SUMMARY OF THE INVENTION

Accordingly, the present invention provides an instruction accelerator which includes a processor and an associative memory. The processor is coupled to receive a stream of instructions and a corresponding stream of instruction identifier values. The instructions include at least one non-quick instruction which has a first associated data set which must be accessed prior to executing the non-quick instruction. The associative memory, which is coupled to the processor, stores one or more instruction identifier values and one or more associated data sets. The associative memory also receives the stream of instruction identifier values. When a current instruction identifier value in the stream of instruction identifier values matches an instruction identifier value stored in the memory, an associated data set is accessed from the memory. More specifically, if the first instruction identifier value and the first data set are stored in the memory, and the current instruction identifier value is equal to the first instruction identifier value, then the first data set is read out of the memory. Execution of the non-quick instruction is accelerated because the first data set is readily accessible within the memory. In one embodiment, the associative memory is a content addressable memory.

If the first data set and the first instruction identifier value are not initially stored in the associative memory, then the associative memory will not detect a match between the current instruction identifier value and any of the instruction identifier values stored in the memory when the current instruction is the non-quick instruction. In the absence of such a match, the associative memory asserts a control signal which is provided to the processor. Upon detecting the asserted control signal and the presence of the non-quick instruction, the processor causes a portion of software code to be accessed. This software code locates and retrieves the first data set. The first data set is then loaded into the associative memory, along with the first instruction identifier value.

After initially loading the first data set and the first instruction identifier value into the associative memory, the first data set is readily accessible to accelerate the execution of the non-quick instruction during subsequent execution of the same instruction.

Because the non-quick instruction is not overwritten, the non-quick instruction remains available in its original form. Moreover, because the non-quick instruction is not overwritten, the non-quick instruction can be stored in read only memory.

The present invention further includes a method of accelerating the execution of a non-quick instruction having an associated first instruction identifier value and an associated first data set. This method includes the steps of (1) storing the first instruction identifier value and the first data set in an associative memory, (2) comparing a current instruction identifier value associated with a current instruction with the first instruction identifier value stored in the memory, (3) accessing the first data set stored in the memory when the current instruction identifier value matches the first instruction identifier value, and (4) providing the non-quick instruction, the first instruction identifier value and the first data set to an execution unit for execution when the current instruction identifier value matches the first instruction identifier value.

The present invention further includes another method of accelerating the execution of a non-quick instruction having an associated first instruction identifier value and an associated first data set. This method includes the steps of (1) storing one or more instruction identifier values in a memory, (2) comparing a current instruction identifier value associated with a current instruction with the instruction identifier values stored in the memory, (3) retrieving the first data set from a program memory when the current instruction is the non-quick instruction and the current instruction identifier value is the first instruction identifier value, and the current instruction identifier value does not match any of the instruction identifier values stored in the memory, and (4) loading the retrieved first data set and the first instruction identifier value into the memory.

The present invention will be more fully understood in light of the following detailed description taken together with the drawings.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a block diagram of one embodiment of virtual machine hardware processor that utilizes the non-quick to quick translator cache of this invention.

FIG. 2 is a process flow diagram for generation of virtual machine instructions that are used in one embodiment of this invention.

FIG. 3 illustrates an instruction pipeline implemented in the hardware processor of FIG. 1.

FIG. 4A is an illustration of the one embodiment of the logical organization of a stack structure where each method frame includes a local variable storage area, an environment storage area, and an operand stack utilized by the hardware processor of FIG. 1.

FIG. 4B is an illustration of an alternative embodiment of the logical organization of a stack structure where each method frame includes a local variable storage area and an operand stack on the stack, and an environment storage area for the method frame is included on a separate execution environment stack.

FIG. 4C is an illustration of an alternative embodiment of the stack management unit for the stack and execution environment stack of FIG. 4B.

FIG. 4D is an illustration of one embodiment of the local variables look-aside cache in the stack management unit of FIG. 1.

FIG. 5 illustrates several possible add-ons to the hardware processor of FIG. 1.

FIG. 6 is a block diagram of a portion of a computer system which includes an operand stack, an instruction decoder, a non-quick to quick translator cache (i.e., instruction accelerator), a trap logic circuit, software code and an execution unit in accordance with one embodiment of the present invention.

These and other features and advantages of the present invention will be apparent from the Figures as explained in the Detailed Description of the Invention. Like or similar features are designated by the same reference numeral(s) throughout the drawings and the Detailed Description of the Invention.

DETAILED DESCRIPTION OF THE INVENTION

In accordance with one embodiment of the present invention, a non-quick to quick instruction accelerator is implemented within a hardware processor which is configured to execute virtual computing machine instructions (e.g., JAVA Virtual Machine computing instructions). Such a hardware processor is described below. The description of this hardware processor is followed by a description of a non-quick to quick instruction accelerator which is implemented within the hardware processor. Although the non-quick to quick instruction accelerator is described as being implemented within a particular processor, it is understood that in other embodiments of the invention, the non-quick to quick instruction accelerator can be implemented within any processor which executes non-quick instructions.

FIG. 1 illustrates one embodiment of a virtual machine instruction hardware processor 100, hereinafter hardware processor 100, that includes non-quick to quick translator cache 131 in accordance with the present invention, and that directly executes virtual machine instructions that are processor architecture independent. The performance of hardware processor 100 in executing JAVA virtual machine instructions is much better than high-end CPUs, such as the Intel PENTIUM microprocessor or the Sun Microsystems ULTRASPARC processor, All SPARC trademarks are used under license and are trademarks or registered trademarks of SPARC International, Inc., in the United States and other countries. Products bearing SPARC trademarks are based upon an architecture developed by Sun Microsystems, Inc. PENTIUM is a trademark of Intel Corp. of Sunnyvale, Calif.) interpreting the same virtual machine instructions with a software JAVA interpreter. or with a JAVA just-in-time compiler; is low cost; and exhibits low power consumption. As a result, hardware processor 100 is well suited for portable applications. Hardware processor 100 provides similar advantages for other virtual machine stack-based architectures as well as for virtual machines utilizing features such as garbage collection, thread synchronization, etc.

In view of these characteristics, a system based on hardware processor 100 presents attractive price for performance characteristics, if not the best overall performance, as compared with alternative virtual machine execution environments including software interpreters and just-in-time compilers. Nonetheless, the present invention is not limited to virtual machine hardware processor embodiments, and encompasses any suitable stack-based, or non-stack-based machine implementations, including implementations emulating the JAVA virtual machine as a software interpreter, compiling JAVA virtual machine instructions (either in batch or just-in-time) to machine instruction native to a particular hardware processor, or providing hardware implementing the JAVA virtual machine in microcode, directly in silicon, or in some combination thereof.

Regarding price for performance characteristics, hardware processor 100 has the advantage that the 250 Kilobytes to 500 Kilobytes (Kbytes) of memory storage, e.g., read-only memory or random access memory, typically required by a software interpreter, is eliminated.

A simulation of hardware processor 100 showed that hardware processor 100 executes virtual machine instructions twenty times faster than a software interpreter running a variety of applications on a PENTIUM processor clocked at the same clock rate as hardware processor 100, and executing the same virtual machine instructions. Another simulation of hardware processor 100 showed that hardware processor 100 executes virtual machine instructions five times faster than a just-in-time compiler running on a PENTIUM processor running at the same clock rate as hardware processor 100, and executing the same virtual machine instructions.

In environments in which the expense of the memory required for a software virtual machine instruction interpreter is prohibitive, hardware processor 100 is advantageous. These applications include, for example, an Internet chip for network appliances, a cellular telephone processor, other telecommunications integrated circuits, or other low-power, low-cost applications such as embedded processors, and portable devices.

As used herein, a virtual machine is an abstract computing machine that, like a real computing machine, has an instruction set and uses various memory areas. A virtual machine specification defines a set of processor architecture independent virtual machine instructions that are executed by a virtual machine implementation, e.g., hardware processor 100. Each virtual machine instruction defines a specific operation that is to be performed. The virtual computing machine need not understand the computer language that is used to generate virtual machine instructions or the underlying implementation of the virtual machine. Only a particular file format for virtual machine instructions needs to be understood.

In an exemplary embodiment, the virtual machine instructions are JAVA virtual machine instructions. Each JAVA virtual machine instruction includes one or more bytes that encode instruction identifying information, operands, and any other required information. Section I, which is incorporated herein by reference in its entirety, includes an illustrative set of the JAVA virtual machine instructions. The particular set of virtual machine instructions utilized is not an essential aspect of this invention. In view of the virtual machine instructions in Section I and this disclosure, those of skill in the art can modify the invention for a particular set of virtual machine instructions, or for changes to the JAVA virtual machine specification.

A JAVA compiler JAVAC, (FIG. 2) that is executing on a computer platform, converts an application 201 written in the JAVA computer language to an architecture neutral object file format encoding a compiled instruction sequence 203, according to the JAVA Virtual Machine Specification, that includes a compiled instruction set. However, for this invention, only a source of virtual machine instructions and related information is needed. The method or technique used to generate the source of virtual machine instructions and related information is not essential to this invention.

Compiled instruction sequence 203 is executable on hardware processor 100 as well as on any computer platform that implements the JAVA virtual machine using, for example, a software interpreter or just-in-time compiler. However, as described above, hardware processor 100 provides significant performance advantages over the software implementations.

In this embodiment, hardware processor 100 (FIG. 1) processes the JAVA virtual machine instructions, which include bytecodes. Hardware processor 100, as explained more completely below, executes directly most of the bytecodes. However, execution of some of the bytecodes is implemented via microcode.

One strategy for selecting virtual machine instructions that are executed directly by hardware processor 100 is described herein by way of an example. Thirty percent of the JAVA virtual machine instructions are pure hardware translations; instructions implemented in this manner include constant loading and simple stack operations. The next 50% of the virtual machine instructions are implemented mostly, but not entirely, in hardware and require some firmware assistance; these include stack based operations and array instructions. The next 10% of the JAVA virtual machine instructions are implemented in hardware, but require significant firmware support as well; these include function invocation and function return. The remaining 10% of the JAVA virtual machine instructions are not supported in hardware, but rather are supported by a firmware trap and/or microcode; these include functions such as exception handlers. Herein, firmware means microcode stored in ROM that when executed controls the operations of hardware processor 100.

In one embodiment, hardware processor 100 includes an I/O bus and memory interface unit 110, an instruction cache unit 120 including instruction cache 125, an instruction decode unit 130, a unified execution unit 140, a stack management unit 150 including stack cache 155, a data cache unit 160 including a data cache 165, and program counter and trap control logic 170. Each of these units is described more completely below.

Also, as illustrated in FIG. 1, each unit includes several elements. For clarity and to avoid distracting from the invention, the interconnections between elements within a unit are not shown in FIG. 1. However, in view of the following description, those of skill in the art will understand the interconnections and cooperation between the elements in a unit and between the various units.

The pipeline stages implemented using the units illustrated in FIG. 1 include fetch, decode, execute, and write-back stages. If desired, extra stages for memory access or exception resolution are provided in hardware processor 100.

FIG. 3 is an illustration of a four stage pipeline for execution of instructions in the exemplary embodiment of processor 100. In fetch stage 301, a virtual machine instruction is fetched and placed in instruction buffer 124 (FIG. 1). The virtual machine instruction is fetched from one of (i) a fixed size cache line from instruction cache 125 or (ii) external memory.

With regard to fetching, aside from instructions tableswitch and lookupswitch, (See Section I.) each virtual machine instruction is between one and five bytes long. Thus, to keep things simple, at least forty bits are required to guarantee that all of a given instruction is contained in the fetch.

Another alternative is to always fetch a predetermined number of bytes, for example, four bytes, starting with the opcode. This is sufficient for 95% of JAVA virtual machine instructions (See Section I). For an instruction requiring more than three bytes of operands, another cycle in the front end must be tolerated if four bytes are fetched. In this case, the instruction execution can be started with the first operands fetched even if the full set of operands is not yet available.

In decode stage 302 (FIG. 3), the virtual machine instruction at the front of instruction buffer 124 (FIG. 1) is decoded and instruction folding is performed if possible. Stack cache 155 is accessed only if needed by the virtual machine instruction. Register OPTOP, that contains a pointer OPTOP to a top of a stack 400 (FIG. 4), is also updated in decode stage 302 (FIG. 3).

Herein, for convenience, the value in a register and the register are assigned the same reference numeral. Further, in the following discussion, use of a register to store a pointer is illustrative only of one embodiment. Depending on the specific implementation of the invention, the pointer may be implemented using a hardware register, a hardware counter, a software counter, a software pointer, or other equivalent embodiments known to those of skill in the art. The particular implementation selected is not essential to the invention, and typically is made based on a price to performance trade-off.

In execute stage 303, the virtual machine instruction is executed for one or more cycles.

Typically, in execute stage 303, an ALU in integer unit 142 (FIG. 1) is used either to do an arithmetic computation or to calculate the address of a load or store from data cache unit (DCU) 160. If necessary, traps are prioritized and taken at the end of execute stage 303 (FIG. 3). For control flow instructions, the branch address is calculated in execute stage 303, as well as the condition upon which the branch is dependent.

Cache stage 304 is a non-pipelined stage. Data cache 165 (FIG. 1) is accessed if needed during execution stage 303 (FIG. 3). The reason that stage 304 is non-pipelined is because hardware processor 100 is a stack-based machine. Thus, the instruction following a load is almost always dependent on the value returned by the load. Consequently, in this embodiment, the pipeline is held for one cycle for a data cache access. This reduces the pipeline stages, and the die area taken by the pipeline for the extra registers and bypasses.

Write-back stage 305 is the last stage in the pipeline. In stage 305, the calculated data is written back to stack cache 155.

Hardware processor 100, in this embodiment, directly implements a stack 400 (FIG. 4A) that supports the JAVA virtual machine stack-based architecture (See Section I). Sixty-four entries on stack 400 are contained on stack cache 155 in stack management unit 150. Some entries in stack 400 may be duplicated on stack cache 150. Operations on data are performed through stack cache 155.

Stack 400 of hardware processor 100 is primarily used as a repository of information for methods. At any point in time, hardware processor 100 is executing a single method. Each method has memory space, i.e., a method frame on stack 400, allocated for a set of local variables, an operand stack, and an execution environment structure.

A new method frame, e.g., method frame two 410, is allocated by hardware processor 100 upon a method invocation in execution stage 303 (FIG. 3) and becomes the current frame, i.e., the frame of the current method. Current frame 410 (FIG. 4A), as well as the other method frames, may contain a part of or all of the following six entities, depending on various method invoking situations:

Object reference;

Incoming arguments;

Local variables;

Invoker's method context;

Operand stack; and

Return value from method.

In FIG. 4A, object reference, incoming arguments, and local variables are included in arguments and local variables area 421. The invoker's method context is included in execution environment 422, sometimes called frame state, that in turn includes: a return program counter value 431 that is the address of the virtual machine instruction, e.g., JAVA opcode, next to the method invoke instruction; a return frame 432 that is the location of the calling method's frame; a return constant pool pointer 433 that is a pointer to the calling method's constant pool table; a current method vector 434 that is the base address of the current method's vector table; and a current monitor address 435 that is the address of the current method's monitor.

The object reference is an indirect pointer to an object-storage representing the object being targeted for the method invocation. JAVA compiler JAVAC (See FIG. 2.) generates an instruction to push this pointer onto operand stack 423 prior to generating an invoke instruction. This object reference is accessible as local variable zero during the execution of the method. This indirect pointer is not available for a static method invocation as there is no target-object defined for a static method invocation.

The list of incoming arguments transfers information from the calling method to the invoked method. Like the object reference, the incoming arguments are pushed onto stack 400 by JAVA compiler generated instructions and may be accessed as local variables. JAVA compiler JAVAC (See FIG. 2.) statically generates a list of arguments for current method 410 (FIG. 4A), and hardware processor 100 determines the number of arguments from the list. When the object reference is present in the frame for a non-static method invocation, the first argument is accessible as local variable one. For a static method invocation, the first argument becomes local variable zero.

For 64-bit arguments, as well as 64-bit entities in general, the upper 32-bits, i.e., the 32 most significant bits, of a 64-bit entity are placed on the upper location of stack 400, i.e., pushed on the stack last. For example, when a 64-bit entity is on the top of stack 400, the upper 32-bit portion of the 64-bit entity is on the top of the stack, and the lower 32-bit portion of the 64-bit entity is in the storage location immediately adjacent to the top of stack 400.

The local variable area on stack 400 (FIG. 4A) for current method 410 represents temporary variable storage space which is allocated and remains effective during invocation of method 410. JAVA compiler JAVAC (FIG. 2) statically determines the required number of local variables and hardware processor 100 allocates temporary variable storage space accordingly.

When a method is executing on hardware processor 100, the local variables typically reside in stack cache 155 and are addressed as offsets from pointer VARS (FIGS. 1 and 4A), which points to the position of the local variable zero. Instructions are provided to load the values of local variables onto operand stack 423 and store values from operand stack into local variables area 421.

The information in execution environment 422 includes the invoker's method context. When a new frame is built for the current method, hardware processor 100 pushes the invoker's method context onto newly allocated frame 410, and later utilizes the information to restore the invoker's method context before returning. Pointer FRAME (FIGS. 1 and 4A) is a pointer to the execution environment of the current method. In the exemplary embodiment, each register in register set 144 (FIG. 1) is 32-bits wide.

Operand stack 423 is allocated to support the execution of the virtual machine instructions within the current method. Program counter register PC (FIG. 1) contains the address of the next instruction, e.g., opcode, to be executed. Locations on operand stack 423 (FIG. 4A) are used to store the operands of virtual machine instructions, providing both source and target storage locations for instruction execution. The size of operand stack 423 is statically determined by JAVA compiler JAVAC (FIG. 2) and hardware processor 100 allocates space for operand stack 423 accordingly. Register OPTOP (FIGS. 1 and 4A) holds a pointer to a top of operand stack 423.

The invoked method may return its execution result onto the invoker's top of stack, so that the invoker can access the return value with operand stack references. The return value is placed on the area where an object reference or an argument is pushed before a method invocation.

Simulation results on the JAVA virtual machine indicate that method invocation consumes a significant portion of the execution time (20-40%). Given this attractive target for accelerating execution of virtual machine instructions, hardware support for method invocation is included in hardware processor 100, as described more completely below.

The beginning of the stack frame of a newly invoked method, i.e., the object reference and the arguments passed by the caller, are already stored on stack 400 since the object reference and the incoming arguments come from the top of the stack of the caller. As explained above, following these items on stack 400, the local variables are loaded and then the execution environment is loaded.

One way to speed up this process is for hardware processor 100 to load the execution environment in the background and indicate what has been loaded so far, e.g., simple one bit scoreboarding. Hardware processor 100 tries to execute the bytecodes of the called method as soon as possible, even though stack 400 is not completely loaded. If accesses are made to variables already loaded, overlapping of execution with loading of stack 400 is achieved, otherwise a hardware interlock occurs and hardware processor 100 just waits for the variable or variables in the execution environment to be loaded.

FIG. 4B illustrates another way to accelerate method invocation. Instead of storing the entire method frame in stack 400, the execution environment of each method frame is stored separately from the local variable area and the operand stack of the method frame. Thus, in this embodiment, stack 400B contains modified method frames, e.g. modified method frame 410B having only local variable area 421 and operand stack 423. Execution environment 422 of the method frame is stored in an execution environment memory 440. Storing the execution environment in execution environment memory 440 reduces the amount of data in stack cache 155. Therefore, the size of stack cache 155 can be reduced. Furthermore, execution environment memory 440 and stack cache 155 can be accessed simultaneously. Thus, method invocation can be accelerated by loading or storing the execution environment in parallel with loading or storing data onto stack 400B.

In one embodiment of stack management unit 150, the memory architecture of execution environment memory 440 is also a stack. As modified method frames are pushed onto stack 400B through stack cache 155, corresponding execution environments are pushed onto execution environment memory 440. For example, since modified method frames 0 to 2, as shown in FIG. 4B, are in stack 400B, execution environments (EE) 0 to 2, respectively, are stored in execution environment memory circuit 440.

To further enhance method invocation, an execution environment cache can be added to improve the speed of saving and retrieving the execution environment during method invocation. The architecture described more completely below for stack cache 155, dribbler manager unit 151, and stack control unit 152 for caching stack 400, can also be applied to caching execution environment memory 440.

FIG. 4C illustrates an embodiment of stack management unit 150 modified to support both stack 400B and execution environment memory 440. Specifically, the embodiment of stack management unit 150 in FIG. 4C adds an execution environment stack cache 450, an execution environment dribble manager unit 460, and an execution environment stack control unit 470. Typically, execution dribble manager unit 460 transfers an entire execution environment between execution environment cache 450 and execution environment memory 440 during a spill operation or a fill operation.

I/O Bus and Memory Interface Unit

I/O bus and memory interface unit 110 (FIG. 1), sometimes called interface unit 110, implements an interface between hardware processor 100 and a memory hierarchy which in an exemplary embodiment includes external memory and may optionally include memory storage and/or interfaces on the same die as hardware processor 100. In this embodiment, I/O controller 111 interfaces with external I/O devices and memory controller 112 interfaces with external memory. Herein, external memory means memory external to hardware processor 100. However, external memory either may be included on the same die as hardware processor 100, may be external to the die containing hardware processor 100, or may include both on- and off-die portions.

In another embodiment, requests to I/O devices go through memory controller 112 which maintains an address map of the entire system including hardware processor 100. On the memory bus of this embodiment, hardware processor 100 is the only master and does not have to arbitrate to use the memory bus.

Hence, alternatives for the input/output bus that interfaces with I/O bus and memory interface unit 110 include supporting memory-mapped schemes, providing direct support for PCI, PCMCIA, or other standard busses. Fast graphics (w/VIS or other technology) may optionally be included on the die with hardware processor 100.

I/O bus and memory interface unit 110 generates read and write requests to external memory. Specifically, interface unit 110 provides an interface for instruction cache and data cache controllers 121 and 161 to the external memory. Interface unit 110 includes arbitration logic for internal requests from instruction cache controller 121 and data cache controller 161 to access external memory and in response to a request initiates either a read or a write request on the memory bus to the external memory. A request from data cache controller 121 is always treated as higher priority relative to a request from instruction cache controller 161.

Interface unit 110 provides an acknowledgment signal to the requesting instruction cache controller 121, or data cache controller 161 on read cycles so that the requesting controller can latch the data. On write cycles, the acknowledgment signal from interface unit 110 is used for flow control so that the requesting instruction cache controller 121 or data cache controller 161 does not generate a new request when there is one pending. Interface unit 110 also handles errors generated on the memory bus to the external memory.

Instruction Cache Unit

Instruction cache unit (ICU) 120 (FIG. 1) fetches virtual machine instructions from instruction cache 125 and provides the instructions to instruction decode unit 130. In this embodiment, upon a instruction cache hit, instruction cache controller 121, in one cycle, transfers an instruction from instruction cache 125 to instruction buffer 124 where the instruction is held until integer execution unit IEU, that is described more completely below, is ready to process the instruction. This separates the rest of pipeline 300 (FIG. 3) in hardware processor 100 from fetch stage 301. If it is undesirable to incur the complexity of supporting an instruction-buffer type of arrangement, a temporary one instruction register is sufficient for most purposes. However, instruction fetching, caching, and buffering should provide sufficient instruction bandwidth to support instruction folding as described below.

The front end of hardware processor 100 is largely separate from the rest of hardware processor 100. Ideally, one instruction per cycle is delivered to the execution pipeline.

The instructions are aligned on an arbitrary eight-bit boundary by byte aligner circuit 122 in response to a signal from instruction decode unit 130. Thus, the front end of hardware processor 100 efficiently deals with fetching from any byte position. Also, hardware processor 100 deals with the problems of instructions that span multiple cache lines of cache 125. In this case, since the opcode is the first byte, the design is able to tolerate an extra cycle of fetch latency for the operands. Thus, a very simple de-coupling between the fetching and execution of the bytecodes is possible.

In case of an instruction cache miss, instruction cache controller 121 generates an external memory request for the missed instruction to I/O bus and memory interface unit 110. If instruction buffer 124 is empty, or nearly empty, when there is an instruction cache miss, instruction decode unit 130 is stalled, i.e., pipeline 300 is stalled. Specifically, instruction cache controller 121 generates a stall signal upon a cache miss which is used along with an instruction buffer empty signal to determine whether to stall pipeline 300. Instruction cache 125 can be invalidated to accommodate self-modifying code, e.g., instruction cache controller 121 can invalidate a particular line in instruction cache 125.

Thus, instruction cache controller 121 determines the next instruction to be fetched, i.e., which instruction in instruction cache 125 needs to accessed, and generates address, data and control signals for data and tag RAMs in instruction cache 125. On a cache hit, four bytes of data are fetched from instruction cache 125 in a single cycle, and a maximum of four bytes can be written into instruction buffer 124.

Byte aligner circuit 122 aligns the data out of the instruction cache RAM and feeds the aligned data to instruction buffer 124. As explained more completely below, the first two bytes in instruction buffer 124 are decoded to determine the length of the virtual machine instruction. Instruction buffer 124 tracks the valid instructions in the queue and updates the entries, as explained more completely below.

Instruction cache controller 121 also provides the data path and control for handling instruction cache misses. On an instruction cache miss, instruction cache controller 121 generates a cache fill request to I/O bus and memory interface unit 110.

On receiving data from external memory, instruction cache controller 121 writes the data into instruction cache 125 and the data are also bypassed into instruction buffer 124. Data are bypassed to instruction buffer 124 as soon as the data are available from external memory, and before the completion of the cache fill.

Instruction cache controller 121 continues fetching sequential data until instruction buffer 124 is full or a branch or trap has taken place. In one embodiment, instruction buffer 124 is considered full if there are more than eight bytes of valid entries in buffer 124. Thus, typically, eight bytes of data are written into instruction cache 125 from external memory in response to the cache fill request sent to interface unit 110 by instruction cache unit 120. If there is a branch or trap taken while processing an instruction cache miss, only after the completion of the miss processing is the trap or branch executed.

When an error is generated during an instruction cache fill transaction, a fault indication is generated and stored into instruction buffer 124 along with the virtual machine instruction, i.e., a fault bit is set. The line is not written into instruction cache 125. Thus, the erroneous cache fill transaction acts like a non-cacheable transaction except that a fault bit is set. When the instruction is decoded, a trap is taken.

Instruction cache controller 121 also services non-cacheable instruction reads. An instruction cache enable (ICE) bit, in a processor status register in register set 144, is used to define whether a load can be cached. If the instruction cache enable bit is cleared, instruction cache unit 120 treats all loads as non-cacheable loads. Instruction cache controller 121 issues a non-cacheable request to interface unit 110 for non-cacheable instructions. When the data are available on a cache fill bus for the non-cacheable instruction, the data are bypassed into instruction buffer 124 and are not written into instruction cache 125.

In this embodiment, instruction cache 125 is a direct-mapped, eight-byte line size cache. Instruction cache 125 has a single cycle latency. The cache size is configurable to 0K, 1K, 2K, 4K, 8K and 16K byte sizes where K means kilo. The default size is 4K bytes. Each line has a cache tag entry associated with the line. Each cache tag contains a twenty bit address tag field and one valid bit for the default 4K byte size.

Instruction buffer 124, which, in an exemplary embodiment, is a twelve-byte deep first-in, first-out (FIFO) buffer, de-links fetch stage 301 (FIG. 3) from the rest of pipeline 300 for performance reasons. Each instruction in buffer 124 (FIG. 1) has an associated valid bit and an error bit. When the valid bit is set, the instruction associated with that valid bit is a valid instruction. When the error bit is set, the fetch of the instruction associated with that error bit was an erroneous transaction. Instruction buffer 124 includes an instruction buffer control circuit (not shown) that generates signals to pass data to and from instruction buffer 124 and that keeps track of the valid entries in instruction buffer 124, i.e., those with valid bits set.

In an exemplary embodiment, four bytes can be received into instruction buffer 124 in a given cycle. Up to five bytes, representing up to two virtual machine instructions, can be read out of instruction buffer 124 in a given cycle. Alternative embodiments, particularly those providing folding of multi-byte virtual machine instructions and/or those providing folding of more than two virtual machine instructions, provide higher input and output bandwidth. Persons of ordinary skill in the art will recognize a variety of suitable instruction buffer designs including, for example, alignment logic, circular buffer design, etc. When a branch or trap is taken, all the entries in instruction buffer 124 are nullified and the branch/trap data moves to the top of instruction buffer 124.

In the embodiment of FIG. 1, a unified execution unit 140 is shown. However, in another embodiment, instruction decode unit 120, integer unit 142, and stack management unit 150 are considered a single integer execution unit, and floating point execution unit 143 is a separate optional unit. In still other embodiments, the various elements in the execution unit may be implemented using the execution unit of another processor. In general the various elements included in the various units of FIG. 1 are exemplary only of one embodiment. Each unit could be implemented with all or some of the elements shown. Again, the decision is largely dependent upon a price vs. performance trade-off.

Instruction Decode Unit

As explained above, virtual machine instructions are decoded in decode stage 302 (FIG. 3) of pipeline 300. In an exemplary embodiment, two bytes, that can correspond to two virtual machine instructions, are fetched from instruction buffer 124 (FIG. 1). The two bytes are decoded in parallel to determine if the two bytes correspond to two virtual machine instructions, e.g., a first load top of stack instruction and a second add top two stack entries instruction, that can be folded into a single equivalent operation. Folding refers to supplying a single equivalent operation corresponding to two or more virtual machine instructions.

In an exemplary hardware processor 100 embodiment, a single-byte first instruction can be folded with a second instruction. However, alternative embodiments provide folding of more than two virtual machine instructions, e.g., two to four virtual machine instructions, and of multi-byte virtual machine instructions, though at the cost of instruction decoder complexity and increased instruction bandwidth. See U.S. patent application Ser. No. 08/786,351, entitled "INSTRUCTION FOLDING FOR A STACK-BASED MACHINE" naming Marc Tremblay and James Michael O'Connor as inventors, assigned to the assignee of this application, and filed on even date herewith which is incorporated herein by reference in its entirety. In the exemplary processor 100 embodiment, if the first byte, which corresponds to the first virtual machine instruction, is a multi-byte instruction, the first and second instructions are not folded.

An optional current object loader folder 132 exploits instruction folding, such as that described above, and in greater detail in U.S. patent application Ser. No. 08/786,351, entitled "INSTRUCTION FOLDING FOR A STACK-BASED MACHINE" naming Marc Tremblay and James Michael O'Connor as inventors, assigned to the assignee of this application, and filed on even date herewith, which is incorporated herein by reference in its entirety, in virtual machine instruction sequences which simulation results have shown to be particularly frequent and therefore a desirable target for optimization. In particular, method invocations typically load an object reference for the corresponding object onto the operand stack and fetch a field from the object. Instruction folding allow this extremely common virtual machine instruction sequence to be executed using an equivalent folded operation.

Quick variants are not part of the virtual machine instruction set (See Chapter 3 of Section I), and are invisible outside of a JAVA virtual machine implementation. However, inside a virtual machine implementation, quick variants have proven to be an effective optimization. (See Section A in Appendix I;

which is an integral part of this specification.) Supporting writes for updates of various instructions to quick variants in a non-quick to quick translator cache 131 changes the normal virtual machine instruction to a quick virtual machine instruction to take advantage of the large benefits bought from the quick variants. In particular, as described below, when the information required to initiate execution of an instruction has been assembled for the first time, the information is stored in a cache along with the value of program counter PC as tag in non-quick to quick translator cache 131 and the instruction is identified as a quick-variant. In one embodiment, this is done with self-modifying code.

Upon a subsequent call of that instruction, instruction decode unit 130 detects that the instruction is identified as a quick-variant and simply retrieves the information needed to initiate execution of the instruction from non-quick to quick translator cache 131. Non-quick to quick translator cache is an optional feature of hardware processor 100.

With regard to branching, a very short pipe with quick branch resolution is sufficient for most implementations. However, an appropriate simple branch prediction mechanism can alternatively be introduced, e.g., branch predictor circuit 133. Implementations for branch predictor circuit 133 include branching based on opcode, branching based on offset, or branching based on a two-bit counter mechanism.

The JAVA virtual machine specification defines an instruction invokenonvirtual, opcode 183, which, upon execution, invokes methods. The opcode is followed by an index byte one and an index byte two. (See Section I.) Operand stack 423 contains a reference to an object and some number of arguments when this instruction is executed.

Index bytes one and two are used to generate an index into the constant pool of the current class. The item in the constant pool at that index points to a complete method signature and class. Signatures are defined in Section I and that description is incorporated herein by reference.

The method signature, a short, unique identifier for each method, is looked up in a method table of the class indicated. The result of the lookup is a method block that indicates the type of method and the number of arguments for the method. The object reference and arguments are popped off this method's stack and become initial values of the local variables of the new method. The execution then resumes with the first instruction of the new method. Upon execution, instructions invokevirtual, opcode 182, and invokestatic, opcode 184, invoke processes similar to that just described. In each case, a pointer is used to lookup a method block.

A method argument cache 134, that also is an optional feature of hardware processor 100, is used, in a first embodiment, to store the method block of a method for use after the first call to the method, along with the pointer to the method block as a tag. Instruction decode unit 130 uses index bytes one and two to generate the pointer and then uses the pointer to retrieve the method block for that pointer in cache 134. This permits building the stack frame for the newly invoked method more rapidly in the background in subsequent invocations of the method. Alternative embodiments may use a program counter or method identifier as a reference into cache 134. If there is a cache miss, the instruction is executed in the normal fashion and cache 134 is updated accordingly. The particular process used to determine which cache entry is overwritten is not an essential aspect of this invention. A least-recently used criterion could be implemented, for example.

In an alternative embodiment, method argument cache 134 is used to store the pointer to the method block, for use after the first call to the method, along with the value of program counter PC of the method as a tag. Instruction decode unit 130 uses the value of program counter PC to access cache 134. If the value of program counter PC is equal to one of the tags in cache 134, cache 134 supplies the pointer stored with that tag to instruction decode unit 130. Instruction decode unit 139 uses the supplied pointer to retrieve the method block for the method. In view of these two embodiments, other alternative embodiments will be apparent to those of skill in the art.

Wide index forwarder 136, which is an optional element of hardware processor 100, is a specific embodiment of instruction folding for instruction wide. Wide index forwarder 136 handles an opcode encoding an extension of an index operand for an immediately subsequent virtual machine instruction. In this way, wide index forwarder 136 allows instruction decode unit 130 to provide indices into local variable storage 421 when the number of local variables exceeds that addressable with a single byte index without incurring a separate execution cycle for instruction wide.

Aspects of instruction decoder 135, particularly instruction folding, non-quick to quick translator cache 131, current object loader folder 132, branch predictor 133, method argument cache 134, and wide index forwarder 136 are also useful in implementations that utilize a software interpreter or just-in-time compiler, since these elements can be used to accelerate the operation of the software interpreter or just-in-time compiler. In such an implementation, typically, the virtual machine instructions are translated to an instruction for the processor executing the interpreter or compiler, e.g., any one of a Sun processor, a DEC processor, an Intel processor, or a Motorola processor, for example, and the operation of the elements is modified to support execution on that processor. The translation from the virtual machine instruction to the other processor instruction can be done either with a translator in a ROM or a simple software translator. For additional examples of dual instruction set processors, see U.S. patent application Ser. No. 08/643,104, now abandoned, entitled "A PROCESSOR FOR EXECUTING INSTRUCTION SETS RECEIVED FROM A NETWORK OR FROM A LOCAL MEMORY" naming Marc Tremblay and James Michael O'Connor as inventors, assigned to the assignee of this application, and filed on even date herewith, which is incorporated herein by reference in its entirety

Integer Execution Unit

Integer execution unit IEU, that includes instruction decode unit 130, integer unit 142, and stack management unit 150, is responsible for the execution of all the virtual machine instructions except the floating point related instructions. The floating point related instructions are executed in floating point unit 143.

Integer execution unit IEU interacts at the front end with instructions cache unit 120 to fetch instructions, with floating point unit (FPU) 143 to execute floating point instructions, and finally with data cache unit (DCU) 160 to execute load and store related instructions. Integer execution unit IEU also contains microcode ROM 141 which contains instructions to execute certain virtual machine instructions associated with integer operations.

Integer execution unit IEU includes a cached portion of stack 400, i.e., stack cache 155. Stack cache 155 provides fast storage for operand stack and local variable entries associated with a current method, e.g., operand stack 423 and local variable storage 421 entries. Although, stack cache 155 may provide sufficient storage for all operand stack and local variable entries associated with a current method, depending on the number of operand stack and local variable entries, less than all of local variable entries or less than all of both local variable entries and operand stack entries may be represented in stack cache 155. Similarly, additional entries, e.g., operand stack and or local variable entries for a calling method, may be represented in stack cache 155 if space allows.

Stack cache 155 is a sixty-four entry thirty-two-bit wide array of registers that is physically implemented as a register file in one embodiment. Stack cache 155 has three read ports, two of which are dedicated to integer execution unit IEU and one to dribble manager unit 151. Stack cache 155 also has two write ports, one dedicated to integer execution unit IEU and one to dribble manager unit 151.

Integer unit 142 maintains the various pointers which are used to access variables, such as local variables, and operand stack values, in stack cache 155. Integer unit 142 also maintains pointers to detect whether a stack cache hit has taken place. Runtime exceptions are caught and dealt with by exception handlers that are implemented using information in microcode ROM 141 and circuit 170.

Integer unit 142 contains a 32-bit ALU to support arithmetic operations. The operations supported by the ALU include: add, subtract, shift, and, or, exclusive or, compare, greater than, less than, and bypass. The ALU is also used to determine the address of conditional branches while a separate comparator determines the outcome of the branch instruction.

The most common set of instructions which executes cleanly through the pipeline is the group of ALU instructions. The ALU instructions read the operands from the top of stack 400 in decode stage 302 and use the ALU in execution stage 303 to compute the result. The result is written back to stack 400 in write-back stage 305. There are two levels of bypass which may be needed if consecutive ALU operations are accessing stack cache 155.

Since the stack cache ports are 32-bits wide in this embodiment, double precision and long data operations take two cycles. A shifter is also present as part of the ALU. If the operands are not available for the instruction in decode stage 302, or at a maximum at the beginning of execution stage 303, an interlock holds the pipeline stages before execution stage 303.

The instruction cache unit interface of integer execution unit IEU is a valid/accept interface, where instruction cache unit 120 delivers instructions to integer decode unit 130 in fixed fields along with valid bits. Instruction decoder 135 responds by signaling how much byte aligner circuit 122 needs to shift, or how many bytes instruction decode unit 130 could consume in decode stage 302. The instruction cache unit interface also signals to instruction cache unit 120 the branch mis-predict condition, and the branch address in execution stage 303. Traps, when taken, are also similarly indicated to instruction cache unit 120. Instruction cache unit 120 can hold integer unit 142 by not asserting any of the valid bits to instruction decode unit 130. Instruction decode unit 130 can hold instruction cache unit 120 by not asserting the shift signal to byte aligner circuit 122.

The data cache interface of integer execution unit IEU also is a valid-accept interface, where integer unit 142 signals, in execution stage 303, a load or store operation along with its attributes, e.g., non-cached, special stores etc., to data cache controller 161 in data cache unit 160. Data cache unit 160 can return the data on a load, and control integer unit 142 using a data control unit hold signal. On a data cache hit, data cache unit 160 returns the requested data, and then releases the pipeline.

On store operations, integer unit 142 also supplies the data along with the address in execution stage 303. Data cache unit 165 can hold the pipeline in cache stage 304 if data cache unit 165 is busy, e.g., doing a line fill etc.

Floating point operations are dealt with specially by integer execution unit IEU. Instruction decoder 135 fetches and decodes floating point unit 143 related instructions. Instruction decoder 135 sends the floating point operation operands for execution to floating point unit 142 in decode state 302. While floating point unit 143 is busy executing the floating point operation, integer unit 142 halts the pipeline and waits until floating point unit 143 signals to integer unit 142 that the result is available.

A floating point ready signal from floating point unit 143 indicates that execution stage 303 of the floating point operation has concluded. In response to the floating point ready signal, the result is written back into stack cache 155 by integer unit 142. Floating point load and stores are entirely handled by integer execution unit IEU, since the operands for both floating point unit 143 and integer unit 142 are found in stack cache 155.

Stack Management Unit

A stack management unit 150 stores information, and provides operands to execution unit 140. Stack management unit 150 also takes care of overflow and underflow conditions of stack cache 155.

In one embodiment, stack management unit 150 includes stack cache 155 that, as described above, is a three read port, two write port register file in one embodiment; a stack control unit 152 which provides the necessary control signals for two read ports and one write port that are used to retrieve operands for execution unit 140 and for storing data back from a write-back register or data cache 165 into stack cache 155; and a dribble manager 151 which speculatively dribbles data in and out of stack cache 155 into memory whenever there is an overflow or underflow in stack cache 155. In the exemplary embodiment of FIG. 1, memory includes data cache 165 and any memory storage interfaced by memory interface unit 110. In general, memory includes any suitable memory hierarchy including caches, addressable read/write memory storage, secondary storage, etc. Dribble manager 151 also provides the necessary control signals for a single read port and a single write port of stack cache 155 which are used exclusively for background dribbling purposes.

In one embodiment, stack cache 155 is managed as a circular buffer which ensures that the stack grows and shrinks in a predictable manner to avoid overflows or overwrites. The saving and restoring of values to and from data cache 165 is controlled by dribbler manager 151 using high- and low-water marks, in one embodiment.

Stack management unit 150 provides execution unit 140 with two 32-bit operands in a given cycle. Stack management unit 150 can store a single 32-bit result in a given cycle.

Dribble manager 151 handles spills and fills of stack cache 155 by speculatively dribbling the data in and out of stack cache 155 from and to data cache 165. Dribble manager 151 generates a pipeline stall signal to stall the pipeline when a stack overflow or underflow condition is detected. Dribble manager 151 also keeps track of requests sent to data cache unit 160. A single request to data cache unit 160 is a 32-bit consecutive load or store request.

The hardware organization of stack cache 155 is such that, except for long operands (long integers and double precision floating-point numbers), implicit operand fetches for opcodes do not add latency to the execution of the opcodes. The number of entries in operand stack 423 (FIG. 4A) and local variable storage 422 that are maintained in stack cache 155 represents a hardware/performance tradeoff. At least a few operand stack 423 and local variable storage 422 entries are required to get good performance. In the exemplary embodiment of FIG. 1, at least the top three entries of operand stack 423 and the first four local variable storage 422 entries are preferably represented in stack cache 155.

One key function provided by stack cache 155 (FIG. 1) is to emulate a register file where access to the top two registers is always possible without extra cycles. A small hardware stack is sufficient if the proper intelligence is provided to load/store values from/to memory in the background, therefore preparing stack cache 155 for incoming virtual machine instructions.

As indicated above, all items on stack 400 (regardless of size) are placed into a 32-bit word. This tends to waste space if many small data items are used, but it also keeps things relatively simple and free of lots of tagging or muxing. An entry in stack 400 thus represents a value and not a number of bytes. Long integer and double precision floating-point numbers require two entries. To keep the number of read and write ports low, two cycles to read two long integers or two double precision floating point numbers are required.

The mechanism for filling and spilling the operand stack from stack cache 155 out to memory by dribble manager 151 can assume one of several alternative forms. One register at a time can be filled or spilled, or a block of several registers filled or spilled at once. A simple scoreboarded method is appropriate for stack management. In its simplest form, a single bit indicates if the register in stack cache 155 is currently valid. In addition, some embodiments of stack cache 155 use a single bit to indicate whether the data content of the register is saved to stack 400, i.e., whether the register is dirty. In one embodiment, a high-water mark/low-water mark heuristic determines when entries are saved to and restored from stack 400, respectively (FIG. 4A). Alternatively, when the top-of-the-stack becomes close to bottom 401 of stack cache 155 by a fixed, or alternatively, a programmable number of entries, the hardware starts loading registers from stack 400 into stack cache 155. For other embodiments of stack management unit 150 and dribble manager unit 151 see U.S. patent application Ser. No. 08/787,736, entitled "METHODS AND APPARATI FOR STACK CACHING" naming Marc Tremblay and James Michael O'Connor as inventors, assigned to the assignee of this application, and filed on even date herewith, which is incorporated herein by reference in its entirety, and see also U.S. patent application Ser. No. 08/787,617, entitled "METHOD FRAME STORAGE USING MULTIPLE MEMORY CIRCUITS" naming Marc Tremblay and James Michael O'Connor as inventors, assigned to the assignee of this application, and filed on even date herewith, which also is incorporated herein by reference in its entirety.

In one embodiment, stack management unit 150 also includes an optional local variable look-aside cache 153. Cache 153 is most important in applications where both the local variables and operand stack 423 (FIG. 4A) for a method are not located on stack cache 155. In such instances when cache 153 is not included in hardware processor 100, there is a miss on stack cache 155 when a local variable is accessed, and execution unit 140 accesses data cache unit 160, which in turn slows down execution. In contrast, with cache 153, the local variable is retrieved from cache 153 and there is no delay in execution.

One embodiment of local variable look-aside cache 153 is illustrated in FIG. 4D for method 0 to 2 on stack 400. Local variables zero to M, where M is an integer, for method 0 are stored in plane 421A₋₋ 0 of cache 153 and plane 421A₋₋ 0 is accessed when method number 402 is zero. Local variables zero to N, where N is an integer, for method 1 are stored in plane 421A₋₋ 1 of cache 153 and plane 421A₋₋ 1 is accessed when method number 402 is one. Local variables zero to P, where P is an integer, for method 1 are stored in plane 421A₋₋ 2 of cache 153 and plane 421A₋₋ 2 is accessed when method number 402 is two. Notice that the various planes of cache 153 may be different sizes, but typically each plane of the cache has a fixed size that is empirically determined.

When a new method is invoked, e.g, method 2, a new plane 421A₋₋ 2 in cache 153 is loaded with the local variables for that method, and method number register 402, which in one embodiment is a counter, is changed, e.g., incremented, to point to the plane of cache 153 containing the local variables for the new method. Notice that the local variables are ordered within a plane of cache 153 so that cache 153 is effectively a direct-mapped cache. Thus, when a local variable is needed for the current method, the variable is accessed directly from the most recent plane in cache 153, i.e., the plane identified by method number 402. When the current method returns, e.g., method 2, method number register 402 is changed, e.g., decremented, to point at previous plane 421A-1 of cache 153. Cache 153 can be made as wide and as deep as necessary.

Data Cache Unit

Data cache unit 160 (DCU) manages all requests for data in data cache 165. Data cache requests can come from dribbling manager 151 or execution unit 140. Data cache controller 161 arbitrates between these requests giving priority to the execution unit requests. In response to a request, data cache controller 161 generates address, data and control signals for the data and tags RAMs in data cache 165. For a data cache hit, data cache controller 161 reorders the data RAM output to provide the right data.

Data cache controller 161 also generates requests to I/O bus and memory interface unit 110 in case of data cache misses, and in case of non-cacheable loads and stores. Data cache controller 161 provides the data path and control logic for processing non-cacheable requests, and the data path and data path control functions for handling cache misses.

For data cache hits, data cache unit 160 returns data to execution unit 140 in one cycle for loads. Data cache unit 160 also takes one cycle for write hits. In case of a cache miss, data cache unit 160 stalls the pipeline until the requested data is available from the external memory. For both non-cacheable loads and stores, data cache 161 is bypassed and requests are sent to I/O bus and memory interface unit 110. Non-aligned loads and stores to data cache 165 trap in software.

Data cache 165 is a two-way set associative, write back, write allocate, 16-byte line cache. The cache size is configurable to 0, 1, 2, 4, 8, 16 Kbyte sizes. The default size is 8 Kbytes. Each line has a cache tag store entry associated with the line. On a cache miss, 16 bytes of data are written into cache 165 from external memory.

Each data cache tag contains a 20-bit address tag field, one valid bit, and one dirty bit. Each cache tag is also associated with a least recently used bit that is used for replacement policy. To support multiple cache sizes, the width of the tag fields also can be varied. If a cache enable bit in processor service register is not set, loads and stores are treated like non-cacheable instructions by data cache controller 161.

A single sixteen-byte write back buffer is provided for writing back dirty cache lines which need to be replaced. Data cache unit 160 can provide a maximum of four bytes on a read and a maximum of four bytes of data can be written into cache 161 in a single cycle. Diagnostic reads and writes can be done on the caches.

Memory Allocation Accelerator

In one embodiment, data cache unit 165 includes a memory allocation accelerator 166. Typically, when a new object is created, fields for the object are fetched from external memory, stored in data cache 165 and then the field is cleared to zero. This is a time consuming process that is eliminated by memory allocation accelerator 166. When a new object is created, no fields are retrieved from external memory. Rather, memory allocation accelerator 160 simply stores a line of zeros in data cache 165 and marks that line of data cache 165 as dirty. Memory allocation accelerator 166 is particularly advantageous with a write-back cache. Since memory allocation accelerator 166 eliminates the external memory access each time a new object is created, the performance of hardware processor 100 is enhanced.

Floating Point Unit

Floating point unit (FPU) 143 includes a microcode sequencer, input/output section with input/output registers, a floating point adder, i.e., an ALU, and a floating point multiply/divide unit. The microcode sequencer controls the microcode flow and microcode branches. The input/output section provides the control for input/output data transactions, and provides the input data loading and output data unloading registers. These registers also provide intermediate result storage.

The floating point adder-ALU includes the combinatorial logic used to perform the floating point adds, floating point subtracts, and conversion operations. The floating point multiply/divide unit contains the hardware for performing multiply/divide and remainder.

Floating point unit 143 is organized as a microcoded engine with a 32-bit data path. This data path is often reused many times during the computation of the result. Double precision operations require approximately two to four times the number of cycles as single precision operations. The floating point ready signal is asserted one-cycle prior to the completion of a given floating point operation. This allows integer unit 142 to read the floating point unit output registers without any wasted interface cycles. Thus, output data is available for reading one cycle after the floating point ready signal is asserted.

Execution Unit Accelerators

Since the JAVA Virtual Machine Specification of Section I is hardware independent, the virtual machine instructions are not optimized for a particular general type of processor, e.g., a complex instruction set computer (CISC) processor, or a reduced instruction set computer (RISC) processor. In fact, some virtual machine instructions have a CISC nature and others a RISC nature. This dual nature complicates the operation and optimization of hardware processor 100.

For example, the JAVA virtual machine specification defines opcode 171 for an instruction lookupswitch, which is a traditional switch statement. The datastream to instruction cache unit 120 includes an opcode 171, identifying the N-way switch statement, that is followed by zero to three bytes of padding. The number of bytes of padding is selected so that first operand byte begins at an address that is a multiple of four. Herein, datastream is used generically to indicate information that is provided to a particular element, block, component, or unit.

Following the padding bytes in the datastream are a series of pairs of signed four-byte quantities. The first pair is special. A first operand in the first pair is the default offset for the switch statement that is used when the argument, referred to as an integer key, or alternatively, a current match value, of the switch statement is not equal to any of the values of the matches in the switch statement. The second operand in the first pair defines the number of pairs that follow in the datastream.

Each subsequent operand pair in the datastream has a first operand that is a match value, and a second operand that is an offset. If the integer key is equal to one of the match values, the offset in the pair is added to the address of the switch statement to define the address to which execution branches. Conversely, if the integer key is unequal to any of the match values, the default offset in the first pair is added to the address of the switch statement to define the address to which execution branches. Direct execution of this virtual machine instruction requires many cycles.

To enhance the performance of hardware processor 100, a look-up switch accelerator 145 is included in hardware processor 100. Look-up switch accelerator 145 includes an associative memory which stores information associated with one or more lookup switch statements. For each lookup switch statement, i.e., each instruction lookupswitch, this information includes a lookup switch identifier value, i.e., the program counter value associated with the lookup switch statement, a plurality of match values and a corresponding plurality of jump offset values.

Lookup switch accelerator 145 determines whether a current instruction received by hardware processor 100 corresponds to a lookup switch statement stored in the associative memory. Lookup switch accelerator 145 further determines whether a current match value associated with the current instruction corresponds with one of the match values stored in the associative memory. Lookup switch accelerator 145 accesses a jump offset value from the associative memory when the current instruction corresponds to a lookup switch statement stored in the memory and the current match value corresponds with one of the match values stored in the memory wherein the accessed jump offset value corresponds with the current match value.

Lookup switch accelerator 145 further includes circuitry for retrieving match and jump offset values associated with a current lookup switch statement when the associative memory does not already contain the match and jump offset values associated with the current lookup switch statement. Lookup switch accelerator 145 is described in more detail in U.S. patent application Ser. No. 08/788,811, entitled "LOOK-UP SWITCH ACCELERATOR AND METHOD OF OPERATING SAME" naming Marc Tremblay and James Michael O'Connor as inventors, assigned to the assignee of this application, and filed on even date herewith, which is incorporated herein by reference in its entirety.

In the process of initiating execution of a method of an object, execution unit 140 accesses a method vector to retrieve one of the method pointers in the method vector, i.e., one level of indirection. Execution unit 140 then uses the accessed method pointer to access a corresponding method, i.e., a second level of indirection.

To reduce the levels of indirection within execution unit 140, each object is provided with a dedicated copy of each of the methods to be accessed by the object. Execution unit 140 then accesses the methods using a single level of indirection. That is, each method is directly accessed by a pointer which is derived from the object. This eliminates a level of indirection which was previously introduced by the method pointers. By reducing the levels of indirection, the operation of execution unit 140 can be accelerated. The acceleration of execution unit 140 by reducing the levels of indirection experienced by execution unit 140 is described in more detail in U.S. patent application Ser. No. 08/787,846, now U.S. Pat. No. 5,970,242 entitled "REPLICATING CODE TO ELIMINATE A LEVEL OF INDIRECTION DURING EXECUTION OF AN OBJECT ORIENTED COMPUTER PROGRAM" naming Marc Tremblay and James Michael O'Connor as inventors, assigned to the assignee of this application, and filed on even date herewith, which is incorporated herein by reference in its entirety.

Getfield-putfield Accelerator

Other specific functional units and various translation lookaside buffer (TLB) types of structures may optionally be included in hardware processor 100 to accelerate accesses to the constant pool. For example, the JAVA virtual machine specification defines an instruction putfield, opcode 181, that upon execution sets a field in an object and an instruction getfield, opcode 180, that upon execution fetches a field from an object. In both of these instructions, the opcode is followed by an index byte one and an index byte two. Operand stack 423 contains a reference to an object followed by a value for instruction putfield, but only a reference to an object for instruction getfield.

Index bytes one and two are used to generate an index into the constant pool of the current class. The item in the constant pool at that index is a field reference to a class name and a field name. The item is resolved to a field block pointer which has both the field width, in bytes, and the field offset, in bytes.

An optional getfield-putfield accelerator 146 in execution unit 140 stores the field block pointer for instruction getfield or instruction putfield in a cache, for use after the first invocation of the instruction, along with the index used to identify the item in the constant pool that was resolved into the field block pointer as a tag. Subsequently, execution unit 140 uses index bytes one and two to generate the index and supplies the index to getfield-putfield accelerator 146. If the index matches one of the indexes stored as a tag, i.e., there is a hit, the field block pointer associated with that tag is retrieved and used by execution unit 140. Conversely, if a match is not found, execution unit 140 performs the operations described above. Getfield-putfield accelerator 146 is implemented without using self-modifying code that was used in one embodiment of the quick instruction translation described above.

In one embodiment, getfield-putfield accelerator 146 includes an associative memory that has a first section that holds the indices that function as tags, and a second section that holds the field block pointers. When an index is applied through an input section to the first section of the associative memory, and there is a match with one of the stored indices, the field block pointer associated with the stored index that matched in input index is output from the second section of the associative memory.

Bounds Check Unit

Bounds check unit 147 (FIG. 1) in execution unit 140 is an optional hardware circuit that checks each access to an element of an array to determine whether the access is to a location within the array. When the access is to a location outside the array, bounds check unit 147 issues an active array bound exception signal to execution unit 140. In response to the active array bound exception signal, execution unit 140 initiates execution of an exception handler stored in microcode ROM 141 that handles the out of bounds array access.

In one embodiment, bounds check unit 147 includes an associative memory element in which is stored an array identifier for an array, e.g., a program counter value, and a maximum value and a minimum value for the array. When an array is accessed, i.e, the array identifier for that array is applied to the associative memory element, and assuming the array is represented in the associative memory element, the stored minimum value is a first input signal to a first comparator element, sometimes called a comparison element, and the stored maximum value is a first input signal to a second comparator element, sometimes also called a comparison element. A second input signal to the first and second comparator elements is the value associated with the access of the array's element.

If the value associated with the access of the array's element is less than or equal to the stored maximum value and greater than or equal to the stored minimum value, neither comparator element generates an output signal. However, if either of these conditions is false, the appropriate comparator element generates the active array bound exception signal. A more detailed description of one embodiment of bounds check unit 147 is provided in U.S. patent application Ser. No. 08/642,248, now abandoned, entitled "PROCESSOR WITH ACCELERATED ARRAY ACCESS BOUNDS CHECKING" naming Marc Tremblay, James Michael O'Connor, and William N. Joy as inventors, assigned to the assignee of this application, and filed on even date herewith which is incorporated herein by reference in its entirety.

The JAVA Virtual Machine Specification defines that certain instructions can cause certain exceptions. The checks for these exception conditions are implemented, and a hardware/software mechanism for dealing with them is provided in hardware processor 100 by information in microcode ROM 141 and program counter and trap control logic 170. The alternatives include having a trap vector style or a single trap target and pushing the trap type on the stack so that the dedicated trap handler routine determines the appropriate action.

No external cache is required for the architecture of hardware processor 100. No translation lookaside buffers need be supported.

FIG. 5 illustrates several possible add-ons to hardware processor 100 to create a unique system. Circuits supporting any of the eight functions shown, i.e., NTSC encoder 501, MPEG 502, Ethernet controller 503, VIS 504, ISDN 505, I/O controller 506, ATM assembly/reassembly 507, and radio link 508 can be integrated into the same chip as hardware processor 100 of this invention.

Non-quick to quick translator cache

FIG. 6 is a block diagram of a portion of a computer system 1 which includes operand stack 423, instruction decoder 135, non-quick to quick translator cache 131, trap logic circuit 170, software search code 31, 32 and 33 and execution unit 140 in accordance with one embodiment of the present invention. In the described embodiment, instruction decoder 135 and non-quick to quick translator cache 131 are found in instruction decode unit 130 (FIG. 1). Non-quick to quick translator cache 131 includes instruction and data processor 12 and associative memory 14. Associative memory 14, in turn, includes instruction identifier memory section 18, data set memory section 20, input circuit 22 and output circuit 24. As described in more detail below, non-quick to quick translator cache 131 stores data sets which are readily accessible to enable the execution of selected non-quick instructions to be greatly accelerated. That is, non-quick to quick translator cache 131 functions as an instruction accelerator.

Instruction decoder 135 is coupled to receive a stream of instructions, such as JAVA byte codes, from instruction cache unit 120. Although the present invention is described in connection with JAVA instructions, the present invention can be applied to accelerate other types of instructions.

In response to the received instructions, instruction decoder 135 provides decoded instructions on bus 11 and program counter (PC) values corresponding to the decoded instructions on bus 13. These instructions and PC values are provided to execution unit 140 and to instruction and data processor 12. In addition, the PC values are provided to input circuit 22 of associative memory 14. In general, each of the PC values uniquely identifies a corresponding instruction. The top entry of operand stack 423 is provided to instruction and data processor 12.

Within associative memory 14, instruction identifier memory section 18 includes a plurality (N) of entries. Each of these N entries is capable of storing a corresponding instruction identifier value, such as instruction identifier values PC₋₋ 0, PC₋₋ 1, PC₋₋ 2, PC₋₋ 3, . . . PC₋₋ N. Each of the instruction identifier values stored in instruction identifier memory section 18 corresponds to a unique PC value. Thus, the width of instruction identifier memory section 18 is selected to correspond with the width of the program counter.

Data set memory section 20 includes the same number of entries (N) as instruction identifier memory section 18. Thus, each entry in instruction identifier section 18 has an associated entry in data set section 20. Each of the N entries of data set memory section 20 is capable of storing a data set, such as data sets DATA₋₋ 0, DATA₋₋ 1, DATA₋₋ 2, DATA₋₋ 3, . . . DATA₋₋ N. As described in more detail below, each of the data sets stored in data set memory section 20 includes the data which is required to execute a non-quick instruction. In the described embodiment, data set memory section 20 has a width of four 32-bit words. However, data set memory section 20 can have other widths in other embodiments.

The number of entries (N) present in instruction identifier memory section 18 and data set memory section 20 is selected in view of the particular application, and can be any integer greater than zero. In general, the number of entries (N) is selected to correspond with the number of non-quick instructions which are to be accelerated. The number of non-quick instructions to be accelerated can be determined by performing simulations which determine the performance achieved for different numbers of entries.

In the described embodiment, associative memory 14 is a content addressable memory which operates as follows. Input circuit 22 is coupled to receive the PC value provided by instruction decoder 135. If the PC value provided to input circuit 22 matches one of the instruction identifier values PC₋₋ 0, PC₋₋ 1, PC₋₋ 2, PC₋₋ 3, . . . PC₋₋ N stored in instruction identifier memory section 18, then the associated data set DATA₋₋ 0, DATA₋₋ 1, DATA₋₋ 2, DATA₋₋ 3, . . . DATA₋₋ N stored in data set memory section 20 is provided to output circuit 24. For example, if the PC value provided to input circuit 22 matches instruction identifier value PC₋₋ 2, then data set DATA₋₋ 2 will be routed through output circuit 24 to execution unit 140. If the PC value provided to input circuit 22 does not match any of the entries of instruction identifier memory section 18, then input circuit 22 asserts a NO₋₋ MATCH signal. The NO₋₋ MATCH signal is provided to instruction and data processor 12 on line 21. Although the present invention is described in connection with a content addressable memory, it is understood that in other embodiments, other types of memories can be used to implement the present invention.

Instruction and data processor 12 monitors each of the instructions provided on bus 11, and determines whether the current instruction on bus 11 is a non-quick instruction which is capable of being executed in an accelerated manner if a corresponding data set is readily accessible. Non-quick instructions which are capable of accelerated execution if a corresponding data set is readily accessible are hereinafter referred to as non-quick instructions having quick variants. Non-quick instructions having quick variants form a subset of the instructions provided by instruction decoder 135. Instruction and data processor 12 can determine whether the current instruction is a non-quick instruction having a quick variant by decoding an identifying portion (or portions) of the current instruction. In the described example, there are a plurality of non-quick instructions which have quick variants, namely, instructions INST₋₋ 0, INST₋₋ 1 . . . INST₋₋ N. The JAVA virtual machine specification describes the following non-quick instructions which have quick variants: anewarray, checkcast, getfield, getstatic, instanceof, invokeinterface, invokespecial, invokestatic, invokevirtual, ldc, ldc₋₋ w, ldc2₋₋ w, multianewarray, new, putfield, and putstatic. These instructions are described in more detail in the JAVA virtual machine specification, which is attached hereto as Section I (See Appendix A of Section I).

Non-quick to quick translator cache 131 operates as follows in response to a current instruction having a current PC value. Instruction decoder 135 provides the current PC value and the decoded current instruction to execution unit 140 and to instruction and data processor 12. Instruction and data processor 12 is only activated when the decoded instruction is a non-quick instruction having a quick variant, a quick variant load instruction, or a retry instruction. The quick variant load and retry instructions are described in more detail below. If the current instruction provided by instruction decoder 135 on bus 11 is not a non-quick instruction having a quick variant, a quick variant load instruction or a retry instruction, then instruction and data processor 12 does nothing in response to this instruction. In this case, the current instruction and current PC value are provided to execution unit 140, which executes the current instruction.

However, when the current instruction is a non-quick instruction having a quick variant (e.g., INST₋₋ 0, INST₋₋ 1 . . . INST₋₋ N), instruction and data processor 12 is activated in response to the current instruction. Upon being activated, instruction and data processor 12 determines the status of the NO₋₋ MATCH signal present on line 21. Initially, the instruction identifier values PC₋₋ 0, PC₋₋ 1, PC₋₋ 2, PC₋₋ 3, . . . PC₋₋ N stored in instruction identifier memory section 18 are set to invalid values. Alternatively, `valid` bits associated with the instruction identifier values PC₋₋ 0, PC₋₋ 1, PC₋₋ 2, PC₋₋ 3, . . . PC₋₋ N can be cleared. As a result, the current PC value provided to input circuit 22 will not initially match any of the instruction identifier values stored in instruction identifier memory section 18. Consequently, the NO₋₋ MATCH signal is asserted. The absence of a match between the current PC value and the instruction identifier values PC₋₋ 0, PC₋₋ 1, PC₋₋ 2, PC₋₋ 3 . . . PC₋₋ N indicates that the data set required to execute the current instruction is not stored in associative memory 14. As a result, instruction and data processor 12 must initially locate and retrieve this data set before the execution of the non-quick instruction can be accelerated.

In response to the asserted NO₋₋ MATCH signal and the determination that the current instruction is a non-quick instruction having a quick variant, instruction and data processor 12 asserts a control signal, TRAP. The control signal TRAP is provided to trap logic 170. In response to the control signal TRAP, trap logic 170 temporarily suspends the operation of execution unit 140, and causes a corresponding software code portion 31, 32, 33 to be accessed. The software code portion accessed is dependent upon the non-quick instruction which caused the control signal TRAP to be asserted.

In a particular embodiment, trap logic 170 accesses instruction cache unit 120 using the current PC value to identify the instruction which caused the control signal TRAP to be asserted. A switch statement is then implemented in software to direct execution to the appropriate software code portion (in response to the identified instruction). In alternative embodiments, other methods, such as a trap vector, can be used to direct execution to the appropriate software code portion. Table 1 defines a switch statement which is used in the described embodiment.

                  TABLE 1                                                          ______________________________________                                         SWITCH (IDENTIFIED INSTRUCTION)                                                ______________________________________                                         INST.sub.-- 0:                                                                             BEGIN                                                                                           ACCESS SOFTWARE PORTION 31                                               END                                                     INST.sub.-- 1:                                                                             BEGIN                                                                                     ACCESS SOFTWARE PORTICN 32                                                     END                                                                     .                                                                               .                                                             INST.sub.-- N:                                                                             BEGIN                                                                                     ACCESS SOFTWARE PORTION 33                                                     END                                                     ______________________________________                                    

Thus, when the identified instruction corresponds with INST₋₋ 0, the switch statement causes software code portion 31 to be accessed. Similarly, when the identified instruction corresponds with INST₋₋ 1, the switch statement causes software code portion 32 to be accessed. When the identified instruction corresponds with INST₋₋ N, the switch statement causes software code portion 33 to be accessed. In the described example, the value N of instruction INST₋₋ N is any integer greater than 1. That is, non-quick to quick translator cache 131 can be used to accelerate the execution of any number of non-quick instructions having quick variants. Instructions INST₋₋ 0, INST₋₋ 1, . . . INST₋₋ N are non-quick instructions having quick variants whose execution is to be accelerated by non-quick to quick translator cache 131.

Software code portions 31, 32, and 33 locate and retrieve the data sets required to execute instructions INST₋₋ 0, INST₋₋ 1 and INST₋₋ N, respectively. Stated another way, software code portions 31, 32 and 33 resolve the constant pool entries for instructions INST₋₋ 0, INST₋₋ 1 and INST₋₋ N, respectively.

Software code portions 31, 32 and 33 further cause the retrieved data sets to be loaded into operand stack 423. Software code portions 31, 32, and 33 provide quick variant load instructions to instruction decoder 135 after the retrieved data sets are loaded into operand stack 423. Instruction decoder 135 decodes the received quick variant load instructions. The decoded quick variant load instructions are provided to instruction and data processor 12 on bus 11. Instruction and data processor 12 identifies each quick variant load instruction present on bus 11, and in response, retrieves a corresponding data set which was previously loaded into operand stack 423.

Instruction and data processor 12 then loads the current PC value and the retrieved data set into associative memory 14. In one example, the current PC value is written to the first entry of instruction identifier memory section 18 as instruction identifier value PC₋₋ 0, and the corresponding retrieved data set is written to the first entry of data set section 20 as data set DATA₋₋ 0. The current PC value is routed from instruction and data processor 12 to memory section 18 on bus 15. The data set is routed from instruction and data processor 12 to data set memory section 20 on bus 17. The method used to select the particular entry within memory 14 can be, for example, random, a least recently used (LRU) algorithm or a first in, first out (FIFO) algorithm.

After the current PC value and the retrieved data set have been written to memory 14, instruction and data processor 12 causes the software code to retry the non-quick instruction which caused the control signal TRAP to be asserted. At this time, the current PC value, which is again provided to input circuit 22, matches an instruction identifier value (i.e., PC₋₋ 0) stored within the instruction identifier memory section 18. As a result, the NO₋₋ MATCH signal is not asserted. Consequently, instruction and data processor 12 does not attempt to locate and retrieve a corresponding data set via trap logic 170 and software code portions 31, 32 and 33.

Because the current PC value matches the instruction identifier value PC₋₋ 0, output circuit 24 passes the corresponding data set DATA₋₋ 0 to execution unit 140. Consequently, execution unit 40 receives the current PC value and the current instruction from instruction decoder 135, as well as the associated data set DATA₋₋ 0 from non-quick to quick translator cache 131. In response, execution unit 40 executes the non-quick instruction.

Once the PC value and the data set associated with a non-quick instruction having a quick variant have been loaded into associative memory 14, the non-quick instruction having a quick variant can be subsequently executed without having to access the software code. As a result, the non-quick instruction can be executed much faster than in the prior art (i.e., in a single cycle). Moreover, because the non-quick instruction is not overwritten, the non-quick instruction remains available in its original form. In addition, because the non-quick instruction is not overwritten, the non-quick instruction can be stored in read only memory.

The following example will further clarify the operation of computer system 1. In this example, instruction decoder 135 initially receives non-quick instruction having a quick variant INST₋₋ 1, which has a corresponding PC value of 100. Because the instruction identifier memory section 18 is initially loaded with invalid PC values (or cleared `valid` bits), the current PC value of 100 causes input circuit 22 to assert the NO₋₋ MATCH signal. In response to the NO₋₋ MATCH signal and the determination that instruction INST₋₋ 1 is a non-quick instruction having a quick variant, instruction and data processor 12 asserts the TRAP control signal. Trap logic 170 uses the PC value to identify the current instruction as instruction INST₋₋ 1. In response to the current instruction being identified as instruction INST₋₋ 1, a software switch statement directs execution to software code portion 32. Software code portion 32 then retrieves the data set required to execute instruction INST₋₋ 1, and loads this data set into operand stack 423. Software code portion 32 then provides a quick variant load instruction to instruction decoder 135. In response, instruction decoder 135 provides a decoded quick variant load instruction to instruction and data processor 12. In response, instruction and data processor 12 retrieves the data set from operand stack 423 and loads this data set into the first entry of data set memory section 20 as data set DATA₋₋ 0. Instruction and data processor 12 further loads the current PC value of 100 into the first entry of instruction identifier memory section 18 as instruction identifier value PC₋₋ 0. Instruction and data processor 12 then causes non-quick instruction INST₋₋ 1 and the current PC value of 100 and to be re-asserted on buses 11 and 13, respectively. In one embodiment, instruction and data processor 12 accomplishes this by issuing a RETURN instruction which transfers control back to the instruction that caused the control signal TRAP to be asserted. At this time, input circuit 22 detects a match between the current PC value and instruction identifier value PC₋₋ 0. In response, associative memory 14 provides the data set associated with instruction identifier value PC₋₋ 0 (i.e., data set DATA₋₋ 0) to output circuit 24. Output circuit 24 passes this data set DATA₋₋ 0 to execution unit 140. Execution unit 140 then executes instruction INST₋₋ 1.

Other non-quick instructions having quick variants (e.g., instructions INST₋₋ 0 and INST₋₋ N) which are subsequently received by instruction decoder 135 are handled in a similar manner. For example, a non-quick instruction INST₋₋ 0 having an associated PC value of 200 could result in the PC value of 200 being stored in instruction identifier section 18 as instruction identifier PC₋₋ 1, and the data set associated with instruction INST₋₋ 0 being stored in data set memory section 20 as data set DATA₋₋ 1. Similarly, a non-quick instruction INST₋₋ N having an associated PC value of 300 could result in the PC value of 300 being stored in instruction identifier section 18 as instruction identifier PC₋₋ 2, and the data set associated with instruction INST₋₋ N being stored in data set memory section 20 as data set DATA₋₋ 2.

If a second non-quick instruction INST₋₋ 1 having an associated PC value which is some value other than 100 is received by instruction decoder 135, this second non-quick instruction INST₋₋ 1 is treated in a similar manner as the first non-quick instruction INST₋₋ 1. For example, a second non-quick instruction INST₋₋ 1 having an associated PC value of 400 could result in the PC value of 400 being stored in instruction identifier section 18 as instruction identifier PC₋₋ 3, and the data set associated with the second non-quick instruction INST₋₋ 1 being stored in data set memory section 20 as data set DATA₋₋ 3. Note that the data set associated with the first non-quick instruction INST₋₋ 1 (e.g., data set DATA₋₋ 0) may not be the same as the data set associated with the second non-quick instruction INST₋₋ 1 (e.g, data set DATA₋₋ 3).

Although the invention has been described in connection with several embodiments, it is understood that this invention is not limited to the embodiments disclosed, but is capable of various modifications which would be apparent to a person skilled in the art. For example, if the number of entries in associative memory 14 is less than the number of non-quick instructions having quick variants, then a replacement algorithm can be used to determine which of the non-quick-instructions are to be accelerated by storing associated data sets in the associative memory 14. This replacement algorithm can be random, least recently used (LRU) or first in, first out (FIFO). Moreover, although the present invention has been described in connection with a control signal TRAP, it is understood that in other embodiments, the control signal TRAP can be replaced with a plurality of control signals, with each control signal corresponding to a non-quick instruction having a quick variant. Thus, the invention is limited only by the following claims. ##SPC1## 

We claim:
 1. An instruction accelerator comprising:a processor for receiving a stream of instructions and a corresponding stream of instruction identifier values each of which uniquely identifies a corresponding instruction in the stream of instructions, wherein the instructions comprise a first non-quick instruction which has a first associated data set which must be accessed prior to executing the first non-quick instruction; and a memory coupled to the processor, the memory being adapted to:store one or more instruction identifier values, including a first instruction identifier value which identifies the first non-quick instruction; store one or more data sets, including the first associated data set; receive the stream of instruction identifier values; and compare a current instruction identifier value in the stream of instruction identifier values with the one or more instruction identifier values stored in the memory; wherein a data set is accessed from the memory when the current instruction identifier value in the stream of instruction identifier values matches an instruction identifier value stored in the memory, and wherein the data set remains in the memory for use by a subsequent non-quick instruction.
 2. The instruction accelerator of claim 1, wherein the first instruction identifier value and the first data set are stored in the memory, and wherein the first associated data set is accessed when the current instruction identifier value matches the first instruction identifier value stored in the memory.
 3. The instruction accelerator of claim 1, wherein the memory further comprises an input circuit, the input circuit being adapted to receive the stream of instruction identifier values and compare the current instruction identifier value with the one or more instruction identifier values stored in the memory.
 4. The instruction accelerator of claim 3, wherein the first instruction identifier value and the first data set are stored in the memory, wherein the input circuit compares the current instruction identifier value with the first instruction identifier value.
 5. The instruction accelerator of claim 3, wherein the memory further comprises an output circuit adapted to receive a data set associated with the current instruction identifier value when the input circuit detects that the current instruction identifier value matches an instruction identifier value stored in the memory.
 6. The instruction accelerator of claim 5, wherein the first instruction identifier value and the first data set are stored in the memory, wherein the output circuit receives the first data set when the current instruction identifier value matches the first instruction identifier value.
 7. The instruction accelerator of claim 1, wherein the memory is a content addressable memory.
 8. The instruction accelerator of claim 3, wherein the input circuit causes the processor to locate and retrieve a data set associated with a current instruction associated with the current instruction identifier value from a remote program memory if the current instruction identifier value does not match the instruction identifier values stored in the memory.
 9. The instruction accelerator of claim 8, wherein the input circuit causes the processor to locate and retrieve the first data set when the current instruction identifier value is the first instruction identifier value, and the current instruction identifier value does not match the instruction identifier values stored in the memory.
 10. The instruction accelerator of claim 8, wherein the processor loads the retrieved data set and the current instruction identifier value into the memory.
 11. The instruction accelerator of claim 1 wherein at least one of the data sets includes data from a constant pool entry.
 12. The instruction accelerator of claim 11 wherein the at least one of the data sets including data from a constant pool entry is the first associated data set.
 13. The instruction accelerator of claim 1 wherein the first associated data set has a known value when the first non-quick instruction is received by the processor.
 14. A computer system comprising:an instruction decoder which receives a stream of instructions and provides a stream of decoded instructions and a corresponding stream of instruction identifier values each of which uniquely identifies a corresponding instruction in the stream of instructions; a processor for receiving the stream of decoded instructions and the stream of instruction identifier values, wherein the decoded instructions comprise a first non-quick instruction which has a first associated data set which must be accessed prior to executing the first non-quick instruction; a memory coupled to the processor, the memory being adapted to:store one or more instruction identifier values, including a first instruction identifier value which identifies the first non-quick instruction; store one or more data sets, including the first associated data set; receive the stream of instruction identifier values; and compare a current instruction identifier value in the stream of instruction identifier values with the one or more instruction identifier values stored in the memory; and an execution unit which is coupled to receive the stream of decoded instructions, the stream of instruction identifier values and the data sets stored in the memory; wherein a data set is accessed from the memory when the current instruction identifier value in the stream of instruction identifier values matches an instruction identifier value stored in the memory, and wherein the data set remains in the memory for use by a subsequent non-quick instruction.
 15. The computer system of claim 14, wherein the memory further comprises an input circuit, the input circuit being adapted to receive the stream of instruction identifier values and compare the current instruction identifier value with the one or more instruction identifier values stored in the memory.
 16. The computer system of claim 15, wherein the memory further comprises an output circuit adapted to receive a data set associated with the current instruction identifier value and provide the data set to the execution unit when the input circuit detects that the current instruction identifier value matches an instruction identifier value stored in the memory.
 17. The computer system of claim 14, wherein the memory is a content addressable memory.
 18. The computer system of claim 14, wherein the input circuit instructs the processor to locate and retrieve a data set associated with a current instruction associated with the current instruction identifier value from a remote program memory if the current instruction identifier value does not match the instruction identifier values stored in the memory.
 19. The computer system of claim 18, further comprising a trap logic circuit coupled to the processor, wherein the trap logic circuit suspends operation of the processor while the data set is located and retrieved.
 20. The computer system of claim 18, further comprising an operand stack for storing the retrieved data set.
 21. The computer system of claim 18, further comprising software code for locating and retrieving the data sets.
 22. A method of accelerating the execution of a non-quick instruction which requires the retrieval of an associated first data set before the non-quick instruction can be executed, the non-quick instruction having an associated first instruction identifier value that uniquely identifies the corresponding non-quick instruction, the method comprising the steps of:storing the first instruction identifier value and the first data set in an associative memory; comparing a current instruction identifier value associated with a current instruction with the first instruction identifier value stored in the memory; accessing the first data set stored in the memory when the current instruction identifier value matches the first instruction identifier value; providing the non-quick instruction, the first instruction identifier value and the first data set to an execution unit for execution when the ent instruction identifier value matches the first instruction identifier value; and retaining the first data set in the memory for use by a subsequent non-quick instruction.
 23. A method of accelerating the execution of a non-quick instruction which requires the retrieval of an associated first data set before the non-quick instruction can be executed, the non-quick instruction having an associated first instruction identifier value that uniquely identifies the corresponding non-quick instruction, the method comprising the steps of:storing one or more instruction identifier values in a memory; comparing a current instruction identifier value associated with a current instruction with the instruction identifier values stored in the memory; retrieving the first data set from a program memory when the current instruction is the non-quick instruction and the current instruction identifier value is the first instruction identifier value, and the current instruction identifier value does not match any of the instruction identifier values stored in the memory; loading the retrieved first data set and the first instruction identifier value into the memory and retaining the first data set in the memory for use by a subsequent non-quick instruction. 